# coding: utf8
# datetime: 2021-03-30
# 题目地址: https://leetcode-cn.com/problems/search-a-2d-matrix/


from typing import List


class Solution:
    def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
        if not matrix or not matrix[0]:
            return False
        raws = len(matrix)

        for raw in range(raws):
            if matrix[raw][0]<=target and matrix[raw][-1]>=target:
                for num in matrix[raw]:
                    if num == target:
                        return True
                return False
        return False

a = Solution()
print(a.searchMatrix([[1,3,5,7],[10,11,16,20],[23,30,34,60]], 3))
